package com.stockz.equity.charting.event.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import com.stockz.equity.charting.event.RepaintStockChartPanelEvent;
import com.stockz.equity.charting.view.StockChartPanel;
import com.stockz.equity.charting.view.StockChart;

@Component
public class RepaintStockChartPanelEventListener implements
		ApplicationListener<RepaintStockChartPanelEvent> {

	@Override
	public void onApplicationEvent(RepaintStockChartPanelEvent event) {
		if(event.getSource() instanceof StockChartPanel){
			StockChartPanel stockChartPanel = (StockChartPanel)event.getSource();
			stockChartPanel.repaint();
		}else if(event.getSource() instanceof StockChart){
			StockChart stockChartView = (StockChart)event.getSource();
			stockChartView.getStockChartPanel().repaint();
		}
	}
}
